//函数类型接口
interface searchFunc{
    (source:string,substring:string):boolean;
}
//使用
let mySearchFun:searchFunc;
mySearchFun=function(src:string,sub:string):boolean{
    let result=src.search(sub);
    return result>-1;
}

//可索引类型
interface StringArray {
    [index: number]: string;
  }
  
  let myArray: StringArray;
  myArray = ["Bob", "Fred"];
  
  let myStr: string = myArray[0];

//实现接口
interface ClockInterface{
    currentTime:Date;
    setTime(d:Date);
}

class Clock implements ClockInterface{
    currentTime:Date;
    setTime(s:Date){
        this.currentTime=s;
    }
    constructor(h:number,m:number){}
}

//继承接口
interface Shape{
    color:string,
}
interface PenStroke {
    penWidth: number;
}
interface Square extends Shape,PenStroke{
    sidelength:number
}

let square:Square;
square.color="red";
square.sidelength=10;

//混合类型
interface Counter{
    (start:number):string;
    interval:number;
    reset():void;
}

function getCounter():Counter{
    let counter=<Counter>function(s:number){};
    counter.interval=3;
    counter.reset=function():void{};
    return counter;
}

let c = getCounter();
c(10);
c.reset();
c.interval = 5.0;